package lanqiao;

public class XOR {
    public static void main(String[] args) {
        int[] nums = {9226, 4690, 4873, 1285, 4624, 1596, 6982, 590, 8806, 121, 8399, 8526, 5426, 64, 9655, 7705, 3929, 3588, 7397, 8020, 1311, 5676, 3469, 2325, 1226, 8203, 9524, 3648, 5278, 8647};
        int ret = 0;
        int max = 0;
        long minPowSum = Integer.MAX_VALUE;
        System.out.println("1 :" + minPowSum);
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(nums[i],max);
        }
        System.out.println(max);
        for (int V = max; V >= 0; V--) {
            long powSum = 0;
            for (int i = 0; i < nums.length; i++) {
                ret = V ^ nums[i];
                powSum += ret * ret;
            }
            minPowSum = Math.min(powSum, minPowSum);
        }
        System.out.println(minPowSum);
    }


}
